// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_bigint_from_datetimev2_1_part6") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_bigint_from_datetimev2_1_part6_6_nullable;"
    sql "create table test_cast_to_bigint_from_datetimev2_1_part6_6_nullable(f1 int, f2 datetimev2(1)) properties('replication_num'='1');"
    sql """insert into test_cast_to_bigint_from_datetimev2_1_part6_6_nullable values (0, "0100-12-01 01:01:00.0"),(1, "0100-12-01 01:01:00.0"),(2, "0100-12-01 01:01:00.9"),(3, "0100-12-01 01:01:01.0"),(4, "0100-12-01 01:01:01.0"),(5, "0100-12-01 01:01:01.9"),(6, "0100-12-01 01:01:59.0"),(7, "0100-12-01 01:01:59.0"),(8, "0100-12-01 01:01:59.9"),(9, "0100-12-01 01:59:00.0"),(10, "0100-12-01 01:59:00.0"),(11, "0100-12-01 01:59:00.9"),(12, "0100-12-01 01:59:01.0"),(13, "0100-12-01 01:59:01.0"),(14, "0100-12-01 01:59:01.9"),(15, "0100-12-01 01:59:59.0"),(16, "0100-12-01 01:59:59.0"),(17, "0100-12-01 01:59:59.9"),(18, "0100-12-01 23:00:00.0"),(19, "0100-12-01 23:00:00.0"),
      (20, "0100-12-01 23:00:00.9"),(21, "0100-12-01 23:00:01.0"),(22, "0100-12-01 23:00:01.0"),(23, "0100-12-01 23:00:01.9"),(24, "0100-12-01 23:00:59.0"),(25, "0100-12-01 23:00:59.0"),(26, "0100-12-01 23:00:59.9"),(27, "0100-12-01 23:01:00.0"),(28, "0100-12-01 23:01:00.0"),(29, "0100-12-01 23:01:00.9"),(30, "0100-12-01 23:01:01.0"),(31, "0100-12-01 23:01:01.0"),(32, "0100-12-01 23:01:01.9"),(33, "0100-12-01 23:01:59.0"),(34, "0100-12-01 23:01:59.0"),(35, "0100-12-01 23:01:59.9"),(36, "0100-12-01 23:59:00.0"),(37, "0100-12-01 23:59:00.0"),(38, "0100-12-01 23:59:00.9"),(39, "0100-12-01 23:59:01.0"),
      (40, "0100-12-01 23:59:01.0"),(41, "0100-12-01 23:59:01.9"),(42, "0100-12-01 23:59:59.0"),(43, "0100-12-01 23:59:59.0"),(44, "0100-12-01 23:59:59.9"),(45, "0100-12-28 00:00:00.0"),(46, "0100-12-28 00:00:00.0"),(47, "0100-12-28 00:00:00.9"),(48, "0100-12-28 00:00:01.0"),(49, "0100-12-28 00:00:01.0"),(50, "0100-12-28 00:00:01.9"),(51, "0100-12-28 00:00:59.0"),(52, "0100-12-28 00:00:59.0"),(53, "0100-12-28 00:00:59.9"),(54, "0100-12-28 00:01:00.0"),(55, "0100-12-28 00:01:00.0"),(56, "0100-12-28 00:01:00.9"),(57, "0100-12-28 00:01:01.0"),(58, "0100-12-28 00:01:01.0"),(59, "0100-12-28 00:01:01.9"),
      (60, "0100-12-28 00:01:59.0"),(61, "0100-12-28 00:01:59.0"),(62, "0100-12-28 00:01:59.9"),(63, "0100-12-28 00:59:00.0"),(64, "0100-12-28 00:59:00.0"),(65, "0100-12-28 00:59:00.9"),(66, "0100-12-28 00:59:01.0"),(67, "0100-12-28 00:59:01.0"),(68, "0100-12-28 00:59:01.9"),(69, "0100-12-28 00:59:59.0"),(70, "0100-12-28 00:59:59.0"),(71, "0100-12-28 00:59:59.9"),(72, "0100-12-28 01:00:00.0"),(73, "0100-12-28 01:00:00.0"),(74, "0100-12-28 01:00:00.9"),(75, "0100-12-28 01:00:01.0"),(76, "0100-12-28 01:00:01.0"),(77, "0100-12-28 01:00:01.9"),(78, "0100-12-28 01:00:59.0"),(79, "0100-12-28 01:00:59.0"),
      (80, "0100-12-28 01:00:59.9"),(81, "0100-12-28 01:01:00.0"),(82, "0100-12-28 01:01:00.0"),(83, "0100-12-28 01:01:00.9"),(84, "0100-12-28 01:01:01.0"),(85, "0100-12-28 01:01:01.0"),(86, "0100-12-28 01:01:01.9"),(87, "0100-12-28 01:01:59.0"),(88, "0100-12-28 01:01:59.0"),(89, "0100-12-28 01:01:59.9"),(90, "0100-12-28 01:59:00.0"),(91, "0100-12-28 01:59:00.0"),(92, "0100-12-28 01:59:00.9"),(93, "0100-12-28 01:59:01.0"),(94, "0100-12-28 01:59:01.0"),(95, "0100-12-28 01:59:01.9"),(96, "0100-12-28 01:59:59.0"),(97, "0100-12-28 01:59:59.0"),(98, "0100-12-28 01:59:59.9"),(99, "0100-12-28 23:00:00.0"),
      (100, "0100-12-28 23:00:00.0"),(101, "0100-12-28 23:00:00.9"),(102, "0100-12-28 23:00:01.0"),(103, "0100-12-28 23:00:01.0"),(104, "0100-12-28 23:00:01.9"),(105, "0100-12-28 23:00:59.0"),(106, "0100-12-28 23:00:59.0"),(107, "0100-12-28 23:00:59.9"),(108, "0100-12-28 23:01:00.0"),(109, "0100-12-28 23:01:00.0"),(110, "0100-12-28 23:01:00.9"),(111, "0100-12-28 23:01:01.0"),(112, "0100-12-28 23:01:01.0"),(113, "0100-12-28 23:01:01.9"),(114, "0100-12-28 23:01:59.0"),(115, "0100-12-28 23:01:59.0"),(116, "0100-12-28 23:01:59.9"),(117, "0100-12-28 23:59:00.0"),(118, "0100-12-28 23:59:00.0"),(119, "0100-12-28 23:59:00.9"),
      (120, "0100-12-28 23:59:01.0"),(121, "0100-12-28 23:59:01.0"),(122, "0100-12-28 23:59:01.9"),(123, "0100-12-28 23:59:59.0"),(124, "0100-12-28 23:59:59.0"),(125, "0100-12-28 23:59:59.9"),(126, "2025-01-01 00:00:00.0"),(127, "2025-01-01 00:00:00.0"),(128, "2025-01-01 00:00:00.9"),(129, "2025-01-01 00:00:01.0"),(130, "2025-01-01 00:00:01.0"),(131, "2025-01-01 00:00:01.9"),(132, "2025-01-01 00:00:59.0"),(133, "2025-01-01 00:00:59.0"),(134, "2025-01-01 00:00:59.9"),(135, "2025-01-01 00:01:00.0"),(136, "2025-01-01 00:01:00.0"),(137, "2025-01-01 00:01:00.9"),(138, "2025-01-01 00:01:01.0"),(139, "2025-01-01 00:01:01.0"),
      (140, "2025-01-01 00:01:01.9"),(141, "2025-01-01 00:01:59.0"),(142, "2025-01-01 00:01:59.0"),(143, "2025-01-01 00:01:59.9"),(144, "2025-01-01 00:59:00.0"),(145, "2025-01-01 00:59:00.0"),(146, "2025-01-01 00:59:00.9"),(147, "2025-01-01 00:59:01.0"),(148, "2025-01-01 00:59:01.0"),(149, "2025-01-01 00:59:01.9"),(150, "2025-01-01 00:59:59.0"),(151, "2025-01-01 00:59:59.0"),(152, "2025-01-01 00:59:59.9"),(153, "2025-01-01 01:00:00.0"),(154, "2025-01-01 01:00:00.0"),(155, "2025-01-01 01:00:00.9"),(156, "2025-01-01 01:00:01.0"),(157, "2025-01-01 01:00:01.0"),(158, "2025-01-01 01:00:01.9"),(159, "2025-01-01 01:00:59.0"),
      (160, "2025-01-01 01:00:59.0"),(161, "2025-01-01 01:00:59.9"),(162, "2025-01-01 01:01:00.0"),(163, "2025-01-01 01:01:00.0"),(164, "2025-01-01 01:01:00.9"),(165, "2025-01-01 01:01:01.0"),(166, "2025-01-01 01:01:01.0"),(167, "2025-01-01 01:01:01.9"),(168, "2025-01-01 01:01:59.0"),(169, "2025-01-01 01:01:59.0"),(170, "2025-01-01 01:01:59.9"),(171, "2025-01-01 01:59:00.0"),(172, "2025-01-01 01:59:00.0"),(173, "2025-01-01 01:59:00.9"),(174, "2025-01-01 01:59:01.0"),(175, "2025-01-01 01:59:01.0"),(176, "2025-01-01 01:59:01.9"),(177, "2025-01-01 01:59:59.0"),(178, "2025-01-01 01:59:59.0"),(179, "2025-01-01 01:59:59.9"),
      (180, "2025-01-01 23:00:00.0"),(181, "2025-01-01 23:00:00.0"),(182, "2025-01-01 23:00:00.9"),(183, "2025-01-01 23:00:01.0"),(184, "2025-01-01 23:00:01.0"),(185, "2025-01-01 23:00:01.9"),(186, "2025-01-01 23:00:59.0"),(187, "2025-01-01 23:00:59.0"),(188, "2025-01-01 23:00:59.9"),(189, "2025-01-01 23:01:00.0"),(190, "2025-01-01 23:01:00.0"),(191, "2025-01-01 23:01:00.9"),(192, "2025-01-01 23:01:01.0"),(193, "2025-01-01 23:01:01.0"),(194, "2025-01-01 23:01:01.9")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"
    qt_sql_6_strict 'select f1, cast(f2 as bigint) from test_cast_to_bigint_from_datetimev2_1_part6_6_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_6_non_strict 'select f1, cast(f2 as bigint) from test_cast_to_bigint_from_datetimev2_1_part6_6_nullable order by 1;'

    sql "drop table if exists test_cast_to_bigint_from_datetimev2_1_part6_6_not_nullable;"
    sql "create table test_cast_to_bigint_from_datetimev2_1_part6_6_not_nullable(f1 int, f2 datetimev2(1)) properties('replication_num'='1');"
    sql """insert into test_cast_to_bigint_from_datetimev2_1_part6_6_not_nullable values (0, "0100-12-01 01:01:00.0"),(1, "0100-12-01 01:01:00.0"),(2, "0100-12-01 01:01:00.9"),(3, "0100-12-01 01:01:01.0"),(4, "0100-12-01 01:01:01.0"),(5, "0100-12-01 01:01:01.9"),(6, "0100-12-01 01:01:59.0"),(7, "0100-12-01 01:01:59.0"),(8, "0100-12-01 01:01:59.9"),(9, "0100-12-01 01:59:00.0"),(10, "0100-12-01 01:59:00.0"),(11, "0100-12-01 01:59:00.9"),(12, "0100-12-01 01:59:01.0"),(13, "0100-12-01 01:59:01.0"),(14, "0100-12-01 01:59:01.9"),(15, "0100-12-01 01:59:59.0"),(16, "0100-12-01 01:59:59.0"),(17, "0100-12-01 01:59:59.9"),(18, "0100-12-01 23:00:00.0"),(19, "0100-12-01 23:00:00.0"),
      (20, "0100-12-01 23:00:00.9"),(21, "0100-12-01 23:00:01.0"),(22, "0100-12-01 23:00:01.0"),(23, "0100-12-01 23:00:01.9"),(24, "0100-12-01 23:00:59.0"),(25, "0100-12-01 23:00:59.0"),(26, "0100-12-01 23:00:59.9"),(27, "0100-12-01 23:01:00.0"),(28, "0100-12-01 23:01:00.0"),(29, "0100-12-01 23:01:00.9"),(30, "0100-12-01 23:01:01.0"),(31, "0100-12-01 23:01:01.0"),(32, "0100-12-01 23:01:01.9"),(33, "0100-12-01 23:01:59.0"),(34, "0100-12-01 23:01:59.0"),(35, "0100-12-01 23:01:59.9"),(36, "0100-12-01 23:59:00.0"),(37, "0100-12-01 23:59:00.0"),(38, "0100-12-01 23:59:00.9"),(39, "0100-12-01 23:59:01.0"),
      (40, "0100-12-01 23:59:01.0"),(41, "0100-12-01 23:59:01.9"),(42, "0100-12-01 23:59:59.0"),(43, "0100-12-01 23:59:59.0"),(44, "0100-12-01 23:59:59.9"),(45, "0100-12-28 00:00:00.0"),(46, "0100-12-28 00:00:00.0"),(47, "0100-12-28 00:00:00.9"),(48, "0100-12-28 00:00:01.0"),(49, "0100-12-28 00:00:01.0"),(50, "0100-12-28 00:00:01.9"),(51, "0100-12-28 00:00:59.0"),(52, "0100-12-28 00:00:59.0"),(53, "0100-12-28 00:00:59.9"),(54, "0100-12-28 00:01:00.0"),(55, "0100-12-28 00:01:00.0"),(56, "0100-12-28 00:01:00.9"),(57, "0100-12-28 00:01:01.0"),(58, "0100-12-28 00:01:01.0"),(59, "0100-12-28 00:01:01.9"),
      (60, "0100-12-28 00:01:59.0"),(61, "0100-12-28 00:01:59.0"),(62, "0100-12-28 00:01:59.9"),(63, "0100-12-28 00:59:00.0"),(64, "0100-12-28 00:59:00.0"),(65, "0100-12-28 00:59:00.9"),(66, "0100-12-28 00:59:01.0"),(67, "0100-12-28 00:59:01.0"),(68, "0100-12-28 00:59:01.9"),(69, "0100-12-28 00:59:59.0"),(70, "0100-12-28 00:59:59.0"),(71, "0100-12-28 00:59:59.9"),(72, "0100-12-28 01:00:00.0"),(73, "0100-12-28 01:00:00.0"),(74, "0100-12-28 01:00:00.9"),(75, "0100-12-28 01:00:01.0"),(76, "0100-12-28 01:00:01.0"),(77, "0100-12-28 01:00:01.9"),(78, "0100-12-28 01:00:59.0"),(79, "0100-12-28 01:00:59.0"),
      (80, "0100-12-28 01:00:59.9"),(81, "0100-12-28 01:01:00.0"),(82, "0100-12-28 01:01:00.0"),(83, "0100-12-28 01:01:00.9"),(84, "0100-12-28 01:01:01.0"),(85, "0100-12-28 01:01:01.0"),(86, "0100-12-28 01:01:01.9"),(87, "0100-12-28 01:01:59.0"),(88, "0100-12-28 01:01:59.0"),(89, "0100-12-28 01:01:59.9"),(90, "0100-12-28 01:59:00.0"),(91, "0100-12-28 01:59:00.0"),(92, "0100-12-28 01:59:00.9"),(93, "0100-12-28 01:59:01.0"),(94, "0100-12-28 01:59:01.0"),(95, "0100-12-28 01:59:01.9"),(96, "0100-12-28 01:59:59.0"),(97, "0100-12-28 01:59:59.0"),(98, "0100-12-28 01:59:59.9"),(99, "0100-12-28 23:00:00.0"),
      (100, "0100-12-28 23:00:00.0"),(101, "0100-12-28 23:00:00.9"),(102, "0100-12-28 23:00:01.0"),(103, "0100-12-28 23:00:01.0"),(104, "0100-12-28 23:00:01.9"),(105, "0100-12-28 23:00:59.0"),(106, "0100-12-28 23:00:59.0"),(107, "0100-12-28 23:00:59.9"),(108, "0100-12-28 23:01:00.0"),(109, "0100-12-28 23:01:00.0"),(110, "0100-12-28 23:01:00.9"),(111, "0100-12-28 23:01:01.0"),(112, "0100-12-28 23:01:01.0"),(113, "0100-12-28 23:01:01.9"),(114, "0100-12-28 23:01:59.0"),(115, "0100-12-28 23:01:59.0"),(116, "0100-12-28 23:01:59.9"),(117, "0100-12-28 23:59:00.0"),(118, "0100-12-28 23:59:00.0"),(119, "0100-12-28 23:59:00.9"),
      (120, "0100-12-28 23:59:01.0"),(121, "0100-12-28 23:59:01.0"),(122, "0100-12-28 23:59:01.9"),(123, "0100-12-28 23:59:59.0"),(124, "0100-12-28 23:59:59.0"),(125, "0100-12-28 23:59:59.9"),(126, "2025-01-01 00:00:00.0"),(127, "2025-01-01 00:00:00.0"),(128, "2025-01-01 00:00:00.9"),(129, "2025-01-01 00:00:01.0"),(130, "2025-01-01 00:00:01.0"),(131, "2025-01-01 00:00:01.9"),(132, "2025-01-01 00:00:59.0"),(133, "2025-01-01 00:00:59.0"),(134, "2025-01-01 00:00:59.9"),(135, "2025-01-01 00:01:00.0"),(136, "2025-01-01 00:01:00.0"),(137, "2025-01-01 00:01:00.9"),(138, "2025-01-01 00:01:01.0"),(139, "2025-01-01 00:01:01.0"),
      (140, "2025-01-01 00:01:01.9"),(141, "2025-01-01 00:01:59.0"),(142, "2025-01-01 00:01:59.0"),(143, "2025-01-01 00:01:59.9"),(144, "2025-01-01 00:59:00.0"),(145, "2025-01-01 00:59:00.0"),(146, "2025-01-01 00:59:00.9"),(147, "2025-01-01 00:59:01.0"),(148, "2025-01-01 00:59:01.0"),(149, "2025-01-01 00:59:01.9"),(150, "2025-01-01 00:59:59.0"),(151, "2025-01-01 00:59:59.0"),(152, "2025-01-01 00:59:59.9"),(153, "2025-01-01 01:00:00.0"),(154, "2025-01-01 01:00:00.0"),(155, "2025-01-01 01:00:00.9"),(156, "2025-01-01 01:00:01.0"),(157, "2025-01-01 01:00:01.0"),(158, "2025-01-01 01:00:01.9"),(159, "2025-01-01 01:00:59.0"),
      (160, "2025-01-01 01:00:59.0"),(161, "2025-01-01 01:00:59.9"),(162, "2025-01-01 01:01:00.0"),(163, "2025-01-01 01:01:00.0"),(164, "2025-01-01 01:01:00.9"),(165, "2025-01-01 01:01:01.0"),(166, "2025-01-01 01:01:01.0"),(167, "2025-01-01 01:01:01.9"),(168, "2025-01-01 01:01:59.0"),(169, "2025-01-01 01:01:59.0"),(170, "2025-01-01 01:01:59.9"),(171, "2025-01-01 01:59:00.0"),(172, "2025-01-01 01:59:00.0"),(173, "2025-01-01 01:59:00.9"),(174, "2025-01-01 01:59:01.0"),(175, "2025-01-01 01:59:01.0"),(176, "2025-01-01 01:59:01.9"),(177, "2025-01-01 01:59:59.0"),(178, "2025-01-01 01:59:59.0"),(179, "2025-01-01 01:59:59.9"),
      (180, "2025-01-01 23:00:00.0"),(181, "2025-01-01 23:00:00.0"),(182, "2025-01-01 23:00:00.9"),(183, "2025-01-01 23:00:01.0"),(184, "2025-01-01 23:00:01.0"),(185, "2025-01-01 23:00:01.9"),(186, "2025-01-01 23:00:59.0"),(187, "2025-01-01 23:00:59.0"),(188, "2025-01-01 23:00:59.9"),(189, "2025-01-01 23:01:00.0"),(190, "2025-01-01 23:01:00.0"),(191, "2025-01-01 23:01:00.9"),(192, "2025-01-01 23:01:01.0"),(193, "2025-01-01 23:01:01.0"),(194, "2025-01-01 23:01:01.9");
    """

    sql "set enable_strict_cast=true;"
    qt_sql_6_strict 'select f1, cast(f2 as bigint) from test_cast_to_bigint_from_datetimev2_1_part6_6_not_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_6_non_strict 'select f1, cast(f2 as bigint) from test_cast_to_bigint_from_datetimev2_1_part6_6_not_nullable order by 1;'

}